Skip to content

Conversation

@Dayleyfocus
Copy link

@Dayleyfocus Dayleyfocus commented Sep 4, 2025

Introduces a new 'anthropic-compatible' provider with schema, API handler, and UI components for custom Anthropic-compatible endpoints. Updates provider selection, model handling, and settings to support custom base URLs, auth tokens, and model configuration.

Related GitHub Issue

Closes: #

Roo Code Task Context (Optional)

Description

Test Procedure

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

Documentation Updates

Additional Notes

Get in Touch


Important

Adds anthropic-compatible provider with schema, API handler, and UI components for custom Anthropic-compatible endpoints.

  • Behavior:
    • Adds anthropic-compatible provider to provider-settings.ts and providers/anthropic.ts.
    • Implements AnthropicCompatibleHandler in anthropic-compatible.ts for handling API requests with custom base URLs and auth tokens.
    • Updates buildApiHandler() in index.ts to support anthropic-compatible.
  • UI Components:
    • Adds AnthropicCompatible component in AnthropicCompatible.tsx for UI settings.
    • Updates ApiOptions.tsx to include anthropic-compatible in provider selection.
    • Updates constants.ts and providers/index.ts to register anthropic-compatible.
  • Misc:
    • Updates useSelectedModel.ts to handle model selection for anthropic-compatible.
    • Adds translations for anthropic-compatible in settings.json.

This description was created by Ellipsis for 4173863. You can customize this summary. It will automatically update as commits are pushed.

Introduces a new 'anthropic-compatible' provider with schema, API handler, and UI components for custom Anthropic-compatible endpoints. Updates provider selection, model handling, and settings to support custom base URLs, auth tokens, and model configuration.
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. enhancement New feature or request labels Sep 4, 2025
<Button
variant="secondary"
onClick={() => setApiConfigurationField("anthropicCustomModelInfo", openAiModelInfoSaneDefaults)}>
Reset to Defaults
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace the hardcoded 'Reset to Defaults' button text with a translation key to support internationalization.

Suggested change
Reset to Defaults
t("settings:providers.resetToDefaults")

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

Copy link
Contributor

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! I've reviewed the changes and found several issues that need attention before this can be merged.

Critical Issues

  1. Missing GitHub Issue Link - The PR template requires linking to an approved GitHub issue, but the "Closes: #" field is empty. This violates the contribution guidelines.

  2. Incomplete PR Template - Several required sections are not filled out (Description, Test Procedure, Pre-Submission Checklist, etc.)

  3. Missing Tests - No test files found for the new AnthropicCompatibleHandler class or UI component. This significant feature needs test coverage.

  4. Custom Model Info Not Used - The handler doesn't use the custom model info that users configure in the UI (line 244 in anthropic-compatible.ts).

import type { SingleCompletionHandler, ApiHandlerCreateMessageMetadata } from "../index"
import { calculateApiCostAnthropic } from "../../shared/cost"

export class AnthropicCompatibleHandler extends BaseProvider implements SingleCompletionHandler {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This handler appears to be nearly identical to the AnthropicHandler (99% duplicate code). Could we refactor this to extend AnthropicHandler and only override the getModel() method to handle custom model info?

getModel() {
const modelId = this.options.apiModelId
let id = modelId && modelId in anthropicModels ? (modelId as AnthropicModelId) : anthropicDefaultModelId
let info: ModelInfo = anthropicModels[id]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The custom model info (anthropicCustomModelInfo) that users can configure in the UI is not being used here. The handler always falls back to predefined anthropicModels instead of using the custom settings. Should this use: this.options.anthropicCustomModelInfo || anthropicModels[id]?


<div className="flex flex-col gap-3">
<div className="text-sm text-vscode-descriptionForeground whitespace-pre-line">
Custom Model Configuration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These UI labels should use the translation system for internationalization. Consider using t('settings:providers.customModelConfiguration') instead of hardcoded English text.

onInput={handleInputChange("apiModelId")}
placeholder="claude-3-5-sonnet-20241022"
className="w-full">
<label className="block font-medium mb-1">Model Name</label>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing i18n: Should use translation key instead of hardcoded "Model Name"

})}
placeholder="200000"
className="w-full">
<label className="block font-medium mb-1">Context Window Size</label>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing i18n: Should use translation key instead of hardcoded "Context Window Size"

})}
placeholder="8192"
className="w-full">
<label className="block font-medium mb-1">Max Output Tokens</label>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing i18n: Should use translation key instead of hardcoded "Max Output Tokens"

)}

{selectedProviderModels.length > 0 && (
{selectedProviderModels.length > 0 && selectedProvider !== "anthropic-compatible" && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is hiding the model dropdown intentional for anthropic-compatible? Users might want to select from known models before customizing. Consider showing the dropdown but making it optional, or adding a comment explaining why it's hidden.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The model dropdown is intentionally hidden for anthropic-compatible since it's meant to be a generic provider where users type custom model names.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 4, 2025
…le.tsx

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
@hannesrudolph
Copy link
Collaborator

@daniel-lxs talk to me about this plz

@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Sep 4, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Sep 4, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this contribution! I've left some inline comments for your consideration.

getModel() {
const modelId = this.options.apiModelId
let id = modelId && modelId in anthropicModels ? (modelId as AnthropicModelId) : anthropicDefaultModelId
let info: ModelInfo = anthropicModels[id]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed the custom model info from the UI isn't being used here. Was this intentional, or should it be checking for custom settings first?

Suggested change
let info: ModelInfo = anthropicModels[id]
let info: ModelInfo = this.options.anthropicCustomModelInfo || anthropicModels[id]

This would allow the custom context window and capabilities configured in the UI to take effect.

)}

{selectedProviderModels.length > 0 && (
{selectedProviderModels.length > 0 && selectedProvider !== "anthropic-compatible" && (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered adding model fetching from the custom endpoint? It could make the experience smoother by letting users select from a dropdown instead of typing model IDs. Something like:

else if (selectedProvider === "anthropic-compatible" && apiConfiguration?.anthropicBaseUrl) {
  vscode.postMessage({ 
    type: "requestAnthropicCompatibleModels",
    values: {
      baseUrl: apiConfiguration.anthropicBaseUrl,
      apiKey: apiConfiguration.apiKey
    }
  })
}

Though I understand if the manual entry is by design for flexibility with different endpoints.

@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Changes Requested] in Roo Code Roadmap Sep 8, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 23, 2025
@github-project-automation github-project-automation bot moved this from PR [Changes Requested] to Done in Roo Code Roadmap Sep 23, 2025
@hannesrudolph
Copy link
Collaborator

Stale, please make new PR of still interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request PR - Changes Requested size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants